<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>逛水果店</title>
    <style>
        h3{
            text-align: center;
        }
        table{
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div id="app">
        <h3>欢迎光临_vue开发的收银系统_水果店</h3>
        <table width="500" border="1">
            <thead>
                <tr>
                    <th align="center">苹果10￥/斤，折扣<8折></th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="center">
                        <span>请输入你要购买的斤数</span>
                        <input type="number" id="ipt" value="0">
                    </td>
                </tr>
                <tr>
                    <td align="center"><button @click="pay">结账买单</button></td>
                </tr>
                <tr>
                    <td align="center">
                        <span>结账单:</span>
                        <span>总价:</span>
                        <span>{{total}}￥</span>
                        <span>折后价:{{discountPrice}}元</span>
                        <span>省了:{{savePrice}}元</span>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <script src="./vue.js"></script>
    <script>
        const vm = new Vue({
            el:'#app',
            data:{
                total:0,
                discountPrice:0,
                savePrice:0
            },
            methods:{
                pay(){
                    const num = document.querySelector('#ipt').value
                    this.total = num * 10
                    this.discountPrice = this.total * 0.8
                    this.savePrice = this.total - this.discountPrice
                }
            },
            computed:{
                
            }
        })
    </script>
</body>
</html>